<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ page import="cn.com.chec.en.dao.WebsiteInfoDao,cn.com.chec.en.model.domain.WebsiteInfo,java.util.List" %>
<%
cn.com.chec.en.model.domain.UserInfo userInfoSessionNAV = (cn.com.chec.en.model.domain.UserInfo)request.getSession().getAttribute(cn.com.chec.en.constants.Constants.SESSIONNAME);
String navPath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+request.getContextPath() + "/" ;

//接收站点ID
int nav_msgTo = 0 ;
List<WebsiteInfo> nav_websiteInfoList = new WebsiteInfoDao().getSubList(null,0,Integer.MAX_VALUE);
for(WebsiteInfo websiteInfo : nav_websiteInfoList){
	if(websiteInfo.getIsSelf() == 1){
		nav_msgTo = websiteInfo.getId() ;
	}
}
%>
<script type="text/javascript">
	function showUnReadMessage(){
		var url = '<%=navPath%>admin/msgInfo/list.do?isRead=0&msgTo=<%=nav_msgTo%>&rand=' + Math.random();
		parent.NextFrame.location = url ;
	}
	function checkUnReadCount(){
	    var xmlhttp;
		if(window.XMLHttpRequest){
			xmlhttp=new XMLHttpRequest();
		}
		else{
			xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
		}

		xmlhttp.onreadystatechange=function(){
		  if(xmlhttp.readyState==4 && xmlhttp.status==200){
		    document.getElementById("unReadMsgCount").innerHTML=xmlhttp.responseText;
		  }
		}
		xmlhttp.open("GET","<%=navPath%>admin/msgInfo/checkUnReadMsg.do?rand=" + Math.random(),true);
		xmlhttp.send();
	}
</script>
<table cellSpacing="0" cellPadding="0" width="100%" border="0" background="<%=navPath%>styleAdmin/images/top_nav_bg.gif" style="background-repeat:repeat-x;" >
	<tr>
		<td align="left">
			<a href="javascript:history.back(-1);" ><img src="<%=navPath%>styleAdmin/images/priv.gif"  border="0" /></a>&nbsp;&nbsp;&nbsp;
			<a href="javascript:history.go(1);"><img src="<%=navPath%>styleAdmin/images/next.gif"  border="0" /></a>&nbsp;&nbsp;&nbsp;
		</td>
		<td align="right" style="font-size:14px;">
			欢迎:&nbsp;[<%=userInfoSessionNAV.getRealName()%>]&nbsp;&nbsp;角色&nbsp;[<%=userInfoSessionNAV.getRoleInfo().getRoleName() %>]
			[<a  style="font-size:14px;" href="javascript:showUnReadMessage();">您有<font color="red" id="unReadMsgCount"></font>条未读消息</a>]
		  	[<a  style="font-size:14px;" href="<%=navPath%>admin/index/logout" target="_top">注销</a>]
			[<a  style="font-size:14px;" href="<%=navPath%>index.jsp" target="_blank">网站首页</a>]
			[<a  style="font-size:14px;" href="<%=navPath%>help" target="_blank" title="点击查看或下载">帮助文档</a>]
		  	&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	  	</td>
	</tr>
</table>
<script type="text/javascript">
	setInterval(checkUnReadCount,5000);
</script>